<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <!-- 
            如果存在父子组件关系
            先走父组件的 beforeCreate => created => beforeMount => 再走子组件的生命周期
            beforeCreate => created => beforeMount => mounted => 父组件的mounted
         -->
        <child></child>
    </div>
    <script src="./vue/vue.js"></script>
    <script>
        const child = {
            template: `
                <div>这是个子组件</div>
            `,
            beforeCreate() {
                console.log('组件创建之前')
            },

            created() {
                console.log('组件创建之后')
            },

            beforeMount() {
                console.log('组件渲染之前')
            },

            mounted() {
                console.log('组件渲染之后')
            }
        }
        new Vue({
            el: "#app",
            components: {
                child
            },
            beforeCreate() {
                console.log('页面创建之前')
            },

            created() {
                console.log('页面创建之后')
            },

            beforeMount() {
                console.log('页面渲染之前')
            },

            mounted() {
                console.log('页面渲染之后')
            }
        })
    </script>
</body>
</html>